package com.app.xinfadi.base.status;

import android.support.annotation.StringDef;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

/**
 * function:
 * Created by Wutengfei on 2016/2/16.
 */
public class TestStatus {
    //先定义 常量
    public static final String SUNDAY = "0";
    public static final String MONDAY = "1";
    public static final String TUESDAY = "2";
    public static final String WEDNESDAY = "3";
    public static final String THURSDAY = "4";
    public static final String FRIDAY = "5";
    public static final String SATURDAY ="6";

    public TestStatus() {
        setCurrentDay(TestStatus.FRIDAY);
    }

    @WeekDays
    String currentDay = SUNDAY;

    //声明变量
    @WeekDays
    String today = getCurrentDay();

    //用 @IntDef "包住" 常量；
    // @Retention 定义策略
    // 声明构造器
    @StringDef({SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY})
    @Retention(RetentionPolicy.SOURCE)
    public @interface WeekDays {
    }

    public void setCurrentDay(@WeekDays String currentDay) {
        this.currentDay = currentDay;
    }

    @WeekDays
    public String getCurrentDay() {
        return currentDay;
    }

    public String getName(@WeekDays String todayCode) {

        String name = null;
        switch (todayCode) {
            case SUNDAY:
                name = "星期一";
                break;
            case MONDAY:
                name = "星期二";
                break;
            case TUESDAY:
                name = "星期三";
                break;
            case WEDNESDAY:
                name = "星期四";
                break;
            case THURSDAY:
                name = "星期五";
                break;
            case FRIDAY:
                name = "星期六";
                break;
            case SATURDAY:
                name = "星期日";
                break;
            default:
                break;
        }
        return name;
    }
}
